package com.chat.view;

import com.chat.Local;
import com.chat.service.CommonPharse;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.input.MouseEvent;
import javafx.scene.text.Text;
import static com.chat.view.CommonPharseController.com;
import static com.chat.view.MainWindowController.chat;

public class CommonListController {
    public Text commonlang;

    public void setCommonlang(String commonlang) {
        this.commonlang.setText(commonlang);
    }

    public void del(MouseEvent mouseEvent) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("提示");
        alert.setHeaderText("提醒");
        alert.setContentText("删除成功！");
        alert.showAndWait();
        CommonPharse commonPharse=new CommonPharse();
        commonPharse.del(commonlang.getText(), Local.user.getUsername());
        com.removeIf(s->s.getCommonlang().equals(commonlang.getText()));
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                ((javafx.scene.control.TextField) CommonPharseView.$("commonTextField")).setText("");
            }
        });
    }
}
